﻿using System;
using System.Collections.ObjectModel;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Windows.Data;

namespace Spriter.Ui.Converters
{
    [ValueConversion(typeof (string), typeof (string))]
    public class PathValueConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is ObservableCollection<string>)
            {
                var paths = value as ObservableCollection<string>;
                return paths.Select(Path.GetFileName);
            }

            return value;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return value;
        }
    }
}